import java.io.*;

public class IOdemo6 {
    public static void main(String[] args) {
        try(InputStream in=new FileInputStream("D:/picture1.jpg");
            OutputStream out=new FileOutputStream("D:/picture2.jpg")) {
            byte[] bytes=new byte[1024];//设置缓冲区
            int a;
            while((a=in.read())!=-1){
                //write(byte[] b,int off,int len)
                out.write(bytes,0,a);
            }
            System.out.println("文件复制成功");

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
